﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using GA.Shared.Interfaces;
using System.Windows;
using System.Runtime.Serialization;
using System.Windows.Data;
using GA.Server.DatabaseManager;
using GA.Shared.Objects;

namespace GA.Server.Objects
{
    public class DatabaseResource : DatabaseObject
    {
        /// <summary>
        /// Identifies the Id Property.
        /// </summary>
        public static readonly DependencyProperty IdProperty =
            DependencyProperty.Register(
                "Id",
                typeof(int),
                typeof(DatabaseResource),
                new PropertyMetadata(-1));

        /// <summary>
        /// Identifies the Name Property.
        /// </summary>
        public static readonly DependencyProperty NameProperty =
            DependencyProperty.Register(
                "Name",
                typeof(string),
                typeof(DatabaseResource),
                new PropertyMetadata(string.Empty));

        /// <summary>
        /// Identifies the Readable Name Property.
        /// </summary>
        public static readonly DependencyProperty ReadableNameProperty =
            DependencyProperty.Register(
                "ReadableName",
                typeof(string),
                typeof(DatabaseResource),
                new PropertyMetadata(string.Empty));

        /// <summary>
        /// Identifies the ItemTypeId Property.
        /// </summary>
        public static readonly DependencyProperty ItemTypeIdProperty =
            DependencyProperty.Register(
                "ItemTypeId",
                typeof(int?),
                typeof(DatabaseResource),
                new PropertyMetadata(null));

        /// <summary>
        /// Identifies the ItemType Property.
        /// </summary>
        public static readonly DependencyProperty ItemTypeProperty =
            DependencyProperty.Register(
                "ItemType",
                typeof(ItemType),
                typeof(DatabaseResource),
                new PropertyMetadata(null));

        /// <summary>
        /// Identifies the FacilityTypeId Property.
        /// </summary>
        public static readonly DependencyProperty FacilityTypeIdProperty =
            DependencyProperty.Register(
                "FacilityTypeId",
                typeof(int?),
                typeof(DatabaseResource),
                new PropertyMetadata(null));

        /// <summary>
        /// Identifies the FacilityType Property.
        /// </summary>
        public static readonly DependencyProperty FacilityTypeProperty =
            DependencyProperty.Register(
                "FacilityType",
                typeof(FacilityType),
                typeof(DatabaseResource),
                new PropertyMetadata(null));

        /// <summary>
        /// Identifies the FacilityBonus Property.
        /// </summary>
        public static readonly DependencyProperty FacilityBonusProperty =
            DependencyProperty.Register(
                "FacilityBonus",
                typeof(double?),
                typeof(DatabaseResource),
                new PropertyMetadata(null));

        /// <summary>
        /// Gets or sets the Id.
        /// </summary>
        
        [DatabaseField("Id", IsKey = true, IsIdentity = true)]
        public int Id
        {
            get { return (int)SafeGetValue(IdProperty); }
            set { SafeSetValue(IdProperty, value); }
        }

        /// <summary>
        /// Gets or sets the Name.
        /// </summary>
        
        [DatabaseField("Name", IsKey = true, IsQuoted = true)]
        public string Name
        {
            get { return (string)SafeGetValue(NameProperty); }
            set { SafeSetValue(NameProperty, value); }
        }

        /// <summary>
        /// Gets or sets the Readable Name.
        /// </summary>
        
        [DatabaseField("ReadableName", IsKey = true, IsQuoted = true)]
        public string ReadableName
        {
            get { return (string)SafeGetValue(ReadableNameProperty); }
            set { SafeSetValue(ReadableNameProperty, value); }
        }

        /// <summary>
        /// Gets or sets the Item Type Id that is unlocked by building the specified FacilityType on this resource.
        /// </summary>
        
        [DatabaseField("ItemTypeId")]
        public int? ItemTypeId
        {
            get { return (int?)SafeGetValue(ItemTypeIdProperty); }
            set { SafeSetValue(ItemTypeIdProperty, value); }
        }

        /// <summary>
        /// Gets or sets the Item Type that is unlocked by building the specified FacilityType on this resource.
        /// </summary>
        
        public ItemType ItemType
        {
            get { return (ItemType)SafeGetValue(ItemTypeProperty); }
            set { SafeSetValue(ItemTypeProperty, value); }
        }

        /// <summary>
        /// Gets or sets the Facility Type Id that is needed to be built on this resource to get the bonus.
        /// </summary>
        
        [DatabaseField("FacilityTypeId")]
        public int? FacilityTypeId
        {
            get { return (int?)SafeGetValue(FacilityTypeIdProperty); }
            set { SafeSetValue(FacilityTypeIdProperty, value); }
        }

        /// <summary>
        /// Gets or sets the Facility Type that is needed to be built on this resource to get the bonus.
        /// </summary>
        
        public FacilityType FacilityType
        {
            get { return (FacilityType)SafeGetValue(FacilityTypeProperty); }
            set { SafeSetValue(FacilityTypeProperty, value); }
        }

        /// <summary>
        /// Gets or sets the bonus associated with this resource.
        /// </summary>
        
        [DatabaseField("FacilityBonus")]
        public double? FacilityBonus
        {
            get { return (double?)SafeGetValue(FacilityBonusProperty); }
            set { SafeSetValue(FacilityBonusProperty, value); }
        }

        public DatabaseResource()
        {
        }

        public DatabaseResource(LinkedDependencyObject baseObject)
            : base(baseObject)
        {
        }

        public DatabaseResource(LinkedDependencyObject baseObject, BindingMode bindingMode)
            : base(baseObject, bindingMode)
        {
        }

        public override void LoadAllPropertyObjects()
        {
            #warning Not Implemented
        }

        public override void LoadPropertyObject(string propertyName)
        {
            #warning Not Implemented
        }
    }
}
